﻿using Coldairarrow.Entity.DTO;
using Coldairarrow.Entity.PB;
using Coldairarrow.Util;
using Coldairarrow.Util.ClassLibrary;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Business.PB
{
    public partial interface IPB_StockUpBusiness
    {
        Task<PageResult<PB_PickUpList>> GetDataListAsync(PageInput<ConditionDTO> input);
        Task<PB_PickUpList> GetTheDataAsync(string id);
        Task AddDataAsync(PB_PickUpList data);
        Task<AjaxResult> AddMaterialData(SaveStockData data);
        /// <summary>
        /// 保存分批次备货
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        Task<AjaxResult> AddStepsPickMain(AddStepsPickMain data);
        /// <summary>
        /// 编辑保存分批次备货
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        Task<AjaxResult> UpdateStepsPickMain(AddStepsPickMain data);
        Task<AddStepsPickMain> GetStepPickMain(String ParentId,string ItemId);
        Task<AjaxResult> UpdateMaterialData(SaveStockData data);
        Task UpdateDataAsync(PB_PickUpList data);
        Task DeleteDataAsync(List<string> ids);

        /// <summary>
        /// 获取备货单对应的包明细
        /// </summary>
        /// <param name="stockupQrCode">备货单二维码</param>
        /// <returns></returns>
        Task<List<PB_UnLoadListDataDTO>> GetStockUpDetailListDataAsync(string stockupQrCode);

        /// <summary>
        /// 删除备货单已出库的明细
        /// </summary>
        /// <param name="stockupQrCode">备货单二维码</param>
        /// <param name="packqrocde">包二维码</param>
        /// <param name="Nums">包二维码</param>
        /// <returns></returns>
        Task DeleteStockUpDetailListDataAsync(string stockupQrCode,string packqrocde,double Nums);

        /// <summary>
        /// 出库环节,获取包的信息
        /// </summary>
        /// <param name="PackQrcode">包二维码</param>
        /// <param name="stockupQrCode">备货单二维码</param>
        /// <returns></returns>
        Task<StockUpPackDTO> GetStockUpPackDataAsync(string PackQrcode, string stockupQrCode);

        /// <summary>
        /// 出库环节,获取单个成品物料信息
        /// </summary>
        /// <param name="JobQrCode">单个成品二维码</param>
        /// <param name="LocaQrcode">货位二维码</param>
        /// <param name="stockupQrCode">备货单二维码</param>
        /// <returns></returns>
        Task<StockMaterialDTO> GetStockMaterialDataAsync(string JobQrCode,string LocaQrcode, string stockupQrCode);

        /// <summary>
        /// 扫描包出库,并对备货单做对应物料数量做修改
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        Task UpdateStockUpDataAsync(OutStockData data);

        /// <summary>
        /// 出库扫描单个物料
        /// </summary>
        /// <param name="packqrcode">物料二维码</param>
        /// <param name="stockupQrCode">备货单二维码</param>
        /// <param name="locaQrcode">货位二维码</param>
        /// <returns></returns>
        Task<PB_PickUpListDataDTO> GetMaterialDataAsync(string packqrcode, string stockupQrCode,string locaQrcode);

        /// <summary>
        /// 下架出库复核
        /// </summary>
        /// <param name="stockupId">备货单Id</param>
        /// <returns></returns>
        Task SubmitStockUpDataAsync(string stockupId);

        /// <summary>
        /// 下架出库提交
        /// </summary>
        /// <param name="stockupQrCode">备货单二维码</param>
        /// <returns></returns>
        Task SubmitStockUpToReviewAsync(string stockupQrCode);

        /// <summary>
        /// 备货单提交返回未备物料信息
        /// </summary>
        /// <param name="stockupQrCode">备货单二维码</param>
        /// <returns></returns>
        Task<List<StockUpMaterialDTO>> GetStockUpMaterialListAsync(string stockupQrCode);

        /// <summary>
        /// 判断下架出库的包对应货位的项目是否与备货单对应的项目一致
        /// </summary>
        /// <param name="packqrcode">包二维码</param>
        /// <param name="stockupQrCode">备货单二维码</param>
        /// <returns></returns>
        Task<bool> GetLocationProjectTruOrFalseAsync(string packqrcode, string stockupQrCode);

        /// <summary>
        /// 取消备货单提交
        /// </summary>
        /// <param name="stockupQrCode">备货单二维码</param>
        /// 增加取消备货单提交功能   2022-02-20   赵锦涛
        /// <returns></returns>
        Task CancelStockUpAsync(string stockupQrCode);

        /// <summary>
        /// 初始化出库单表数据
        /// 只作用2022-03更新生产库使用
        /// </summary>
        /// <returns></returns>
        Task ResetStockUpDataAsync();


        /// <summary>
        /// 通过发货通知单明细id获取发货计划明细list
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<PageResult<PB_DeliveryPlanDetailsDTO>> GetDeliveryPlanDetails(PageInput<ConditionDTO> input,string ReserveParent);

        /// <summary>
        /// 对7月之前未扫码的备货单做数据处理,生成出库单,更改库存占用量,更改备货单的状态,在备货单Remarks字段增加备货单的备注
        /// </summary>
        /// <param name="PickMainId">备货单ID</param>
        /// <returns></returns>
        Task UpdateInventoryAsync(string PickMainId);
        Task<List<StepsSummary>> GetStepsSummaryList(string ParentId);
        /// <summary>
        /// 通过发货通知单明细获取设计清单步级
        /// </summary>
        /// <param name="ParentId"></param>
        /// <returns></returns>
        Task<int?> GetStepsIndex(string ParentId);
        Task preparationSteps(PreparationStepsSearch data, MongoDBOptions _mongodbOptions);

        /// <summary>
        /// 修改备货单为完成状态
        /// </summary>
        /// <param name="PickMainId">备货单Id</param>
        /// <returns></returns>
        Task SubmitPickMainDataAsync(string PickMainId);

    }

    /// <summary>
    /// 下架出库
    /// </summary>
    public class OutStockData
    {
        /// <summary>
        /// 包码/物料码
        /// </summary>
        public string packqrcode { get; set; }

        /// <summary>
        /// 备货单二维码
        /// </summary>
        public string stockupQrCode { get; set; }

        /// <summary>
        /// 成品二维码
        /// </summary>
        public string JobQrCode { get; set; }

        /// <summary>
        /// 物料数量
        /// </summary>
        public Double? Nums { get; set; }

        /// <summary>
        /// 货位二维码
        /// </summary>
        public string locaqrcode { get; set; }

    }

    public class ResetOutStorageDTO : PB_PickUpList
    {
        /// <summary>
        /// 价格
        /// </summary>
        public Double? Price { get; set; }

        /// <summary>
        /// 仓库Id
        /// </summary>
        public string StorId { get; set; }

        /// <summary>
        /// 货位Id
        /// </summary>
        public string LocalId { get; set; }

        /// <summary>
        /// 备货单Id
        /// </summary>
        public string MainId { get; set; }

        /// <summary>
        /// 项目id
        /// </summary>
        public string ProjectId { get; set; }

        /// <summary>
        /// 清单id
        /// </summary>
        public string DesignId { get; set; }

        /// <summary>
        /// 物料每次扫码出库数量
        /// </summary>
        public Double? Nums { get; set; }

        /// <summary>
        /// 备货单状态
        /// </summary>
        public int? Status { get; set; }

        /// <summary>
        /// 组织Id
        /// </summary>
        public string detpId { get; set; }

        /// <summary>
        /// 工厂Id
        /// </summary>
        public string FactoryId { get; set; }

        /// <summary>
        /// 货区Id
        /// </summary>
        public string AreaIds { get; set; }

        /// <summary>
        /// 工厂Id
        /// </summary>
        public string RackIds { get; set; }

        /// <summary>
        /// 备货单时间
        /// </summary>
        public string Createdate { get; set; }



    }

    /// <summary>
    /// PDA备货扫描成品码出库移除使用
    /// </summary>
    public class UnpackingDetailDTO : PB_UnpackingDetail
    {
        /// <summary>
        /// 包Id
        /// </summary>
        public string PackId { get; set; }
    }

    /// <summary>
    /// 对7月之前未扫码的备货单做数据处理
    /// </summary>
    public class PickUpListModelDTO : PB_PickUpList
    {
        /// <summary>
        /// 备货单创建时间
        /// </summary>
        public DateTime? DeliveryTime { get; set; }

        /// <summary>
        /// 备货单状态
        /// </summary>
        public int? Status { get; set; }

        /// <summary>
        /// 单价
        /// </summary>
        public double? Price { get; set; }

        /// <summary>
        /// 理论重量
        /// </summary>
        public double? Weight { get; set; }

        /// <summary>
        /// 仓库Id
        /// </summary>
        public string StorId { get; set; }

        /// <summary>
        /// 部门Id
        /// </summary>
        public string DepId { get; set; }

        /// <summary>
        /// 工厂Id
        /// </summary>
        public string FactoryId { get; set; }

        /// <summary>
        /// 项目Id
        /// </summary>
        public string ProjectId { get; set; }

        /// <summary>
        /// 清单Id
        /// </summary>
        public string DesignId { get; set; }

    }

    /// <summary>
    /// PDA备货移除单个成品物料
    /// </summary>
    public class UnLoadListMaterialDTO : PB_UnLoadList
    {

        /// <summary>
        /// 物料名称
        /// </summary>
        public string MaterialName { get; set; }

        /// <summary>
        /// 单价
        /// </summary>
        public double? Price { get; set; }

        /// <summary>
        /// 仓库单位
        /// </summary>
        public string storageId { get; set; }
        /// <summary>
        /// 仓库Id
        /// </summary>
        public string StorId { get; set; }
    }

    /// <summary>
    /// PDA备货单提交检查库存占用量是否满足
    /// </summary>
    public class PickListLocaMaterialDTO
    {
        /// <summary>
        /// 备货单Id
        /// </summary>
        public string PickMainId { get; set; }  

        /// <summary>
        /// 物料Id
        /// </summary>
        public string MaterialId { get; set; }

        /// <summary>
        /// 货位Id
        /// </summary>
        public string LocalId { get; set; }

        /// <summary>
        /// 备货单应备数量
        /// </summary>
        public Double? StockVolume { get; set; }

        /// <summary>
        /// 库存占用量
        /// </summary>
        public Double? Nums_R { get; set; }

        /// <summary>
        /// 库存剩余占用量
        /// </summary>
        public Double? SurplusNums { get; set; }

    }

    /// <summary>
    /// 出库包的信息
    /// </summary>
    public class StockUpPackDTO
    {
        /// <summary>
        /// 包Id
        /// </summary>
        public string PackId { get; set; }

        /// <summary>
        /// 包二维码
        /// </summary>
        public string PackQrCode { get; set; }

        /// <summary>
        /// 包名称
        /// </summary>
        public string BoxName { get; set; }

        /// <summary>
        /// 包装数量
        /// </summary>
        public double? Nums { get; set; }

        /// <summary>
        /// 包明细
        /// </summary>
        public List<StockUpPackDetailDTO> StockUpPackDetail { get; set; }

    }

    /// <summary>
    /// 包明细(物料数量)
    /// </summary>
    public class StockUpPackDetailDTO
    {
        /// <summary>
        /// 包Id
        /// </summary>
        public string PackId { get; set; }
        /// <summary>
        /// 物料Id
        /// </summary>
        public string MaterialId { get; set; }

        /// <summary>
        /// 物料名称
        /// </summary>
        public string MaterialName { get; set; }

        /// <summary>
        /// 物料编码
        /// </summary>
        public string MaterialCode { get; set; }

        /// <summary>
        /// 物料规格
        /// </summary>
        public string MaterialSpec { get; set; }

        /// <summary>
        /// 成品编码
        /// </summary>
        public string ProductCode { get; set; }

        /// <summary>
        /// 数量
        /// </summary>
        public double? Nums { get; set; }

        /// <summary>
        /// 未备数量
        /// </summary>
        public double? RemainingQuantity { get; set; }

    }

    /// <summary>
    /// 出库单个成品输入数量
    /// </summary>
    public class StockMaterialDTO
    {
        /// <summary>
        /// 物料Id
        /// </summary>
        public string MaterialId { get; set; }

        /// <summary>
        /// 物料编码
        /// </summary>
        public string MaterialCode { get; set; }

        /// <summary>
        /// 物料名称
        /// </summary>
        public string MaterialName { get; set; }

        /// <summary>
        /// 物料规格
        /// </summary>
        public string MaterialSpec { get; set; }

        /// <summary>
        /// 包Id
        /// </summary>
        public string PackId { get; set; }

        /// <summary>
        /// 包二维码
        /// </summary>
        public string PackQrCode { get; set; }

        /// <summary>
        /// 数量
        /// </summary>
        public double? Nums { get; set; }

        /// <summary>
        /// 未备数量
        /// </summary>
        public double? RemainingQuantity { get; set; }

    }

    /// <summary>
    /// 备货单提交返回未备物料信息
    /// </summary>
    public class StockUpMaterialDTO
    {
        /// <summary>
        /// 物料Id
        /// </summary>
        public string MaterialId { get; set; }

        /// <summary>
        /// 物料编码
        /// </summary>
        public string MaterialName { get; set; }

        /// <summary>
        /// 物料编码
        /// </summary>
        public string MaterialCode { get; set; }

        /// <summary>
        /// 物料规格
        /// </summary>
        public string MaterialSpec { get; set; }

        /// <summary>
        /// 未备数量
        /// </summary>
        public Double? Nums { get; set; }

    }


    /// <summary>
    /// 备货提交获取物料信息
    /// </summary>
    public class UnLoadListDetaialDTO : PB_UnLoadList
    {
        /// <summary>
        /// 单价
        /// </summary>
        public Double? Price { get; set; }

        /// <summary>
        /// 货区Id
        /// </summary>
        public string AreaId { get; set; }

        /// <summary>
        /// 货架Id
        /// </summary>
        public string RackId { get; set; }

        /// <summary>
        /// 仓库Id
        /// </summary>
        public string StorId { get; set; }

    }

}